//
//  Labs_DidMovetoParent_B_DemoVC.swift
//  APSwift
//
//  Created by jianbo.pei on 2022/9/9.
//

import UIKit
import Then
import SnapKit

class Labs_DidMovetoParent_B_DemoVC: Labs_DidMovetoParent_Base_DemoVC {

    override func viewDidLoad() {
        super.viewDidLoad()
        debugPrint("B viewDidLoad")
        
        // Do any additional setup after loading the view.
        view.backgroundColor = .white

        _ = UIButton(type: .custom).then({ make in
            view.addSubview(make)
            make.snp.makeConstraints { make in
                make.size.equalTo(CGSize(width: 200, height: 60))
                make.center.equalToSuperview()
            }
            make.backgroundColor = .yellow
            make.setTitle("返回到A", for: .normal)
            make.setTitleColor(.purple, for: .normal)
            make.addTarget(self, action: #selector(popToA), for: .touchUpInside)
        })
        navigationController?.resetViewControllers()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        debugPrint("B viewWillAppear")
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        debugPrint("B viewDidAppear")
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        debugPrint("B viewWillDisappear")
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        debugPrint("B viewDidDisappear")
    }
    
    @objc private func popToA() {
        debugPrint("\(#function)")
        navigationController?.popViewController(animated: true)
    }
    
    override func willMove(toParent parent: UIViewController?) {
        super.willMove(toParent: parent)
        debugPrint("B willMove | parent is \(String(describing: parent))")
    }
    
    override func didMove(toParent parent: UIViewController?) {
        super.didMove(toParent: parent)
        debugPrint("B didMove | parent is \(String(describing: parent))")
    }
    
}
